<?php
// +----------------------------------------------------------------------
// | 系统模块路由
// +----------------------------------------------------------------------

use owns\middleware\ServerMiddleware;
use owns\middleware\ServerAuthMiddleware;
use think\facade\Route;

/**
 * 管理员登录
 */
Route::group('userlogin', function () {
    Route::post('token', 'login');
})->prefix('system.Login/')->middleware(ServerMiddleware::class);
/**
 * 系统模块
 */
Route::group('system', function () {
    /**
     * 管理员
     */
    Route::group('user', function () {
        Route::get('list', 'list'); //列表
        Route::post('edit', 'edit'); //编辑
        Route::post('resetpassword', 'resetPassword'); //密码重置
        Route::post('delete', 'delete'); //删除
        Route::put('status', 'status');  //状态修改
        Route::put('modifypassword', 'modifyPassword');  //密码修改
        Route::put('modifyuser', 'modifyUser');  //个人信息修改
    })->prefix('system.User/');
    /**
     * 菜单目录
     */
    Route::group('menu', function () {
        Route::get('userMenu', 'userMenu'); //管理员菜单
        Route::get('list', 'list'); //菜单列表
        Route::post('edit', 'edit'); //编辑
        Route::post('delete', 'delete'); //删除
    })->prefix('system.permission.Menu/');
    /**
     * 角色
     */
    Route::group('role', function () {
        Route::get('list', 'list'); //列表
        Route::post('edit', 'edit'); //编辑
        Route::post('permission', 'permission'); //角色权限
        Route::get('roleMenu', 'roleMenu'); //获取角色权限
        Route::put('status', 'status'); //状态
        Route::delete('/', 'delete'); //删除
    })->prefix('system.permission.Role/');
    /**
     * 用户分组
     */
    Route::group('usergroup', function () {
        Route::get('list', 'list'); //列表
        Route::post('edit', 'edit'); //编辑
        Route::delete('delete/:dept_id', 'delete'); //删除
    })->prefix('system.permission.Group/');
    /**
     * 字典
     */
    Route::group('dict', function () {
        Route::get('typeList', 'typeList'); //字典类型列表
        Route::post('typeEdit', 'typeEdit'); //字典类型编辑
        Route::post('typeDelete', 'typeDelete'); //字典类型删除

        Route::get('dataList', 'dataList'); //字典数据列表
        Route::post('dataEdit', 'dataEdit'); //字典数据编辑
        Route::post('dataDelete', 'dataDelete'); //字典数据删除
        Route::post('dataDeletes', 'dataDeletes'); //字典数据批量删除
    })->prefix('system.permission.Dict/');

    /**
     * 公告应用
     */
    Route::group('common', function () {
        /**
         * 系统参数配置
         */
        Route::group('config', function () {
            Route::get('/', 'configList'); //列表
            Route::post('/', 'configSave'); //新增
            Route::put('/', 'configUpdate'); //修改
            Route::delete('/', 'configDelete'); //删除
            Route::get('key/:config_key', 'configKey'); //键值
        });
        /**
         * 公告
         */
        Route::group('notice', function () {
            Route::get('/', 'noticeList'); //列表
            Route::post('/', 'noticeSave'); //新增
            Route::put('/', 'noticeUpdate'); //修改
            Route::delete('/', 'noticeDelete'); //删除
        });
    })->prefix('system.SysCommon/');
    /**
     * 日志
     */
    Route::group('logger', function () {
        //登录日志
        Route::group('login', function () {
            Route::get('list', 'loginList');
        })->prefix('system.Logger/');
        //操作日志
        Route::group('oper', function () {
            Route::get('list', 'operList');
            Route::get('info', 'operInfo');
            Route::get('user', 'userOper');
        })->prefix('system.Logger/');
        //系统日志
        Route::group('system', function () {
            Route::get('list', 'systemList');
        })->prefix('system.Logger/');
    });
    /**
     * 资源文件管理
     */
    Route::group('resource', function () {
        Route::get('type', 'typeList'); //文件类型
        Route::get('/', 'list'); //列表
        Route::post('/', 'edit'); //编辑
        Route::delete('/', 'delete'); //删除
    })->prefix('system.Resource/');
    /**
     * 文件上传相关
     */
    Route::group('file', function () {
        Route::post('uploadImage', 'uploadImage'); //图片文件上传
        Route::post('uploadFile', 'uploadFile'); //附件文件上传
    })->prefix('system.Upload/');
})->middleware(ServerAuthMiddleware::class);
